from itertools import filterfalse

board = [0] * 12
sum = 0
n = 0

def judge(k):
    for i in range(1,k):
        if abs(k - i) == abs(board[k] - board[i]) or board[k] == board[i]:
            return 0
    return 1


def check(a):
    if a > n:
        global sum
        sum += 1
    else:
        return False
    return True

def dfs(a):
    if check(a):
        return
    for i in range(1, n + 1):
        board[a] = i
        if judge(a): #如果能放
            dfs(a + 1)
        else:
            continue


n = int(input())
dfs(1)
print(sum)